package com.atcper

/**
 * @author : ranzlupup
 * @date : 2023/2/24 09:23
 */
object Scala13_String_Test {
    def main(args: Array[String]): Unit = {

        val name = "ranzili"
        println(firstToUpper(name))
        println(firstToUpper2(name))
    }

    def firstToUpper(str: String): String = {
        val option = Option(str)
        if (option.isEmpty) {

        }
        val str1 = str.substring(0, 1).toUpperCase() + str.substring(1)
        str1
    }

    def firstToUpper2(string: String): String = {
        val value = string.getClass.getDeclaredField("value")
        value.setAccessible(true)

        value.set(string, "Ranzili")
        value.toString
    }
}
